home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 039a / dbpcxl15.zip / PCXLIB.H < prev    next >
C/C++ Source or Header  |  1992-01-26  |  4KB  |  128 lines

  1. /* pcxlib.h */
  2. #if !defined(__LARGE__) && !defined(__HUGE__)
  3. #error Wrong memory model
  4. #endif
  5.  
  6. #ifndef PCX_H                      /* don't do more than once */
  7. #define PCX_H
  8.  
  9. #define PCXLIB_VERSION         "1.5"
  10.  
  11. #define ALIGN_DWORD(x) (((x)+3)/4 * 4)
  12. #define What_WPlanes    (SQread_reg(2))
  13.  
  14. #define PCXUNK             -1        /* unknown/invalid */
  15. #define PCXMONO             0
  16. #define PCX4colors          1
  17. #define PCX16colors         2
  18. #define PCX256colors        3
  19.  
  20. struct PCXRGB {
  21.        unsigned char r, g, b;
  22. };
  23.  
  24. typedef struct {
  25.         char               MagicId;
  26.         char               Version;
  27.         char               Encoding;
  28.         char               BitsPixel;
  29.         int                Xmin, Ymin;
  30.         int                Xmax, Ymax;
  31.         int                Hres, Vres;
  32.         struct PCXRGB      Palette[16];   /* used only on 16 color pcx's */
  33.         char               Reserved;
  34.         char               Planes;
  35.         unsigned int       bytesline;
  36.         int                PaletteInfo;
  37.         char               Filler[58];
  38. } PCXH;
  39.  
  40. #define  MAXAREA          65520L       /* 64k - 16 bytes (for malloc) */
  41.  
  42. typedef struct {
  43.        char              *name;
  44.        FILE              *fp;
  45.        PCXH              *h;
  46.        unsigned char     *palette; /* for 256 color pcx's w/palette */
  47.        long              *marks;   /* set to NULL when marks not set */
  48.        unsigned char     *buffer;  /* scan line buffer */
  49.        int               next_scan,buffer_scan;
  50.  
  51.        int               type;    /* PCXUNK= -1 =unknown/invalid
  52.                                      PCXMONO= 0 =mono
  53.                                      PCX4colors     1 =4  color
  54.                                      PCX16colors=   2 =16 color seg/line
  55.                                      PCX256colors=  3 =256 color  */
  56.        unsigned          w, l;
  57.        char              cw, cl;
  58.        long              image_size;
  59.        int               read_or_write;  /* 0 = readonly, 1 = writeonly */
  60.        unsigned          num_marks; /* set to 0 initially */
  61. } PCXF;
  62.  
  63. #ifdef _cplusplus
  64. extern "C" {
  65. #endif
  66.  
  67. PCXF  *        fopenPCXr(char *name);
  68. PCXF  *        fopenPCXw(char *name, PCXH *h, char *palette);
  69. int            fseekPCX(PCXF *pcxfile, unsigned y); /* seek scan line y */
  70. int            fclosePCX(PCXF *pcxfile);
  71.  
  72. int   fread8PCX(char *d, unsigned dw, unsigned dl,
  73.                 unsigned dx, unsigned dy,
  74.                 unsigned x0, unsigned y0, unsigned x1, unsigned y1, PCXF *p);
  75.  
  76. /* fdisp8PCX may be used in VESA modes with no additional work         */
  77. /* (other than  setting the mode) !!                        */
  78. int   fdisp8PCX(unsigned dx, unsigned dy,
  79.                 unsigned x0, unsigned y0, unsigned x1, unsigned y1, PCXF *p);
  80.  
  81. /* fread4PCX reads and converts pixels into a 1 pixel/1 byte format, suitable
  82.    for conversion to a different format */
  83. int   fread4PCX(char *d, unsigned dw, unsigned dl,
  84.                 unsigned dx, unsigned dy,
  85.                 unsigned x0, unsigned y0, unsigned x1, unsigned y1, PCXF *p);
  86. /* fdisp4PCX reads and displays in a VGA planar format */
  87. int   fdisp4PCX(unsigned dx, unsigned dy,
  88.                 unsigned x0, unsigned y0, unsigned x1, unsigned y1, PCXF *p);
  89.  
  90. /* This function for monochrome .pcx files is untested!  I don't have     */
  91. /* any mono pcx files to test it with (I'm not interested in mono files). */
  92. int   fread1PCX(char *d, unsigned dw, unsigned dl, unsigned dx, unsigned dy,
  93.                 unsigned x0, unsigned y0, unsigned x1, unsigned y1, PCXF *p);
  94.  
  95.  
  96. /* low-level read/write */
  97. unsigned       _read_pcx_line(PCXF *pointer, char * linebuffer,
  98.                               unsigned x0, unsigned x1);
  99. unsigned       _write_pcx_line(PCXF *pointer, char * linebuffer,
  100.                                unsigned x0, unsigned x1,
  101.                                unsigned char fill);
  102.  
  103. void           _write_pcx_palette(PCXF *pointer);
  104. void           _read_palette(PCXF *p);
  105.  
  106.  
  107. void           Start_pcxdebug(char *path);
  108. void           Close_pcxdebug(void);
  109.  
  110. #ifdef _cplusplus
  111. }
  112. #endif
  113.  
  114. #ifdef   PCX_LIB
  115.                 int  PCXerror=0;
  116.                 FILE *pcxdebug;
  117.                 int  debugtimeson=0;
  118. #else
  119.          extern int  PCXerror;
  120.          extern FILE *pcxdebug;
  121.          extern int  debugtimeson;
  122. #endif
  123.  
  124. #endif   /* PCX_lib */
  125.  
  126.  
  127.  
  128.